<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>博客</title>
    <link href="<%=basePath%>bootstrap/css/blog-home.css"/>
    <link href="<%=basePath%>bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="<%=basePath%>bootstrap/js/jquery-2.1.1.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"><!--导航条、反色、固定在顶部 -->
    <div class="container"><!--将导航条居中对齐并在两侧添加内补 -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">博客</a><!--设置了内补（padding）和高度（height） -->
        </div>
        <!--导航链接，表格，和切换其他内容-->
        <div class="collapse navbar-collapse"><!--依赖collapse插件、视口足够窄.navbar-collapse内所包含的内容也将不可见-->
            <ul class="nav navbar-nav"><!--导航、导航项-->
                <li><a href="<%=path%>/user?method=index">网站首页</a></li>
            </ul>
            <c:if test="${null!=user&&user.getIsApplied() == 1}">
                <ul class="nav navbar-nav">
                    <li><a href="<%=basePath%>user?method=myblog&userId=${user.id}">我的博客</a></li>
                    <li><a href="<%=basePath%>article?method=manage&userId=${user.id}"><i class="glyphicon glyphicon-cog"></i> 博文管理</a></li><!--Glyphicons字体图标-->
                    <li class="divider"></li><!--分割线-->
                    <li><a href="<%=basePath%>category?method=manage&userId=${user.id}"><i class="glyphicon glyphicon-cog"></i> 分类管理</a></li><!--Glyphicons字体图标-->
                    <li class="divider"></li>
                    <li><a href="<%=basePath%>comment?method=manage&userId=${user.id}"><i class="glyphicon glyphicon-cog"></i> 评论管理</a></li>
                </ul>
            </c:if>
            <c:if test="${user==null}">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="<%=path%>/login.jsp" target="_self">登录</a></li>
                    <li><a href="<%=path%>/register.jsp" target="_self">注册</a></li>
                </ul>
            </c:if>
            <c:if test="${user!=null}">
                <div class="pull-right">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">欢迎，${user.userName}</a></li>
                        <li><a href="<%=basePath%>user?method=profile&id=${user.id}"><i class="glyphicon glyphicon-cog"></i> 编辑个人信息</a></li>
                        <c:if test="${user.isApplied==1}">
                            <li><a href="<%=basePath%>user?method=bloginfo&userId=${user.id}"><i class="glyphicon glyphicon-cog"></i> 编辑博客信息</a></li>
                        </c:if>
                        <li><a href="<%=path%>/user?method=logout"><i class="glyphicon glyphicon-off"></i> 登出</a></li>
                    </ul>
                    </li>
                    </ul>
                </div>
            </c:if>
        </div>
    </div>
</nav>
<c:if test="${null!=succUpdateMsg}">
    <div class="container" style="position: absolute;left: 340px;top: 55px">
        <div class="alert alert-success">
                ${succUpdateMsg}
        </div>
    </div>
    <%
        request.getSession().removeAttribute("succUpdateMsg");
    %>
</c:if>
<c:if test="${null != errorUpdateMsg}">
    <div class="container" style="position: absolute;left: 340px;top: 55px">
        <div class="alert alert-warning">
                ${errorUpdateMsg}
        </div>
    </div>
    <%
        request.getSession().removeAttribute("errorUpdateMsg");
    %>
</c:if>
<c:if test="${null != bi}">
    <div class="container" style="position: absolute;left: 340px;top: 110px">
        <div class="row col-md-6">
            <form class="form-horizontal" action="<%=basePath %>user?method=updatebloginfo&userId=${user.id}" method="post" class="form-horizontal"
                  name="blog_info_form" id="blog_info_form" onsubmit="return isValidate(blog_info_form)">

                <div class="form-group">
                    <label for="email">博客名称</label>
                    <input class="form-control" id="email" name="blog_name" type="text" value="${bi.blogName}" id="blog_name">
                </div>
                <div class="form-group">
                    <label for="address">博客描述</label>
                    <input class="form-control" id="address" name="description" type="text" value="${bi.description}" id="blog_des">
                </div>
                <div class="form-group">
                    <label for="zip">博客公告</label>
                    <textarea class="form-control" id="zip" name="propagate"  rows="5">${bi.propagate}</textarea>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary">保存</button>
                </div>
            </form>
        </div>
    </div>
</c:if>
<c:if test="${null==bi}">
    <%="读取博客信息出错！" %>
</c:if>
<div class="container" style="position: absolute;bottom: 10px;left: 400px">
    <hr>
    <footer style="text-align: center">
        <div class="row">
            <div class="col-lg-12">
                <p>
                    &middot;网站创建到目前访问人数：<%=(Integer)session.getAttribute("num") %>
                </p>
            </div>
        </div>
    </footer>
</div>
<div><audio autoplay="autoplay" loop="true"><source src="music/1.mp3"></audio></div>
</body>
<script type="text/javascript">
    function isValidate(blog_info_form) {
        var blog_name = blog_info_form.blog_name.value;
        var description = blog_info_form.description.value;
        var propagate = blog_info_form.propagate.value;

        if (blog_name == "" || description == "" || propagate == "") {
            alert("博客名称，博客描述，博客公告为必填项");
            return false;
        }
        return true;
    }
</script>
</html>
